<template>
  <div class="login-container">
    <div class="login-body">
      <div class="title-container">
        <div class="tips-title">欢迎登录</div>
        <div class="title">易问通用户平台</div>
      </div>
      <template v-if="logintype === 'login'">
        <div class="tabs-box">
          <div v-for="item in tabList" :key="item.id" class="tabs" :class="{ active: item.url === loginShow }"
            @click="chooseTab(item)">
            {{ item.title }}
            <div class="line"></div>
          </div>
        </div>
        <component :is="loginShow" @runTo="runTo" />
      </template>
      <template v-else>
        <bind :openid="official_openid" @runTo="runTo" />
      </template>
    </div>
  </div>
</template>

<script>
import account from './account.vue'
import ewm from './ewm.vue'
import bind from './bind.vue'
export default {
  name: 'Login',
  components: {
    account,
    ewm,
    bind
  },
  data() {
    return {
      logintype: 'login',
      official_openid: '',
      tabList: [
        { title: '微信登录', url: 'ewm', id: 1 },
        { title: '验证码登录', url: 'account', id: 2 }
      ],
      loginShow: 'account'
    }
  },
  watch: {},
  methods: {
    chooseTab(item) {
      this.loginShow = item.url
    },
    runTo(data) {
      this.logintype = data.type
      this.official_openid = data.data
    }
  }
}
</script>

<style lang="scss" scoped>
$bg: #2d3a4b;
$dark_gray: #889aa4;
$light_gray: #eee;

.login-container {
  min-height: 100%;
  width: 100%;
  background: url('~@/assets/images/logo-bg.jpg') no-repeat;
  background-size: 65% 100%;
  overflow: hidden;
  position: relative;

  .login-body {
    width: 36%;
    height: 100%;
    background: #fff;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 50;
    border-radius: 15px;
    padding-top: 155px;
    padding-left: 100px;
  }

  .title-container {
    position: relative;
    text-align: left;

    .tips-title {
      font-family: PingFang SC, PingFang SC;
      font-weight: 600;
      font-size: 24px;
      color: #9e9e9e;
      line-height: 28px;
    }

    .title {
      font-family: PingFang SC, PingFang SC;
      font-weight: 600;
      font-size: 36px;
      color: #1c1f23;
      line-height: 44px;
      margin: 8px 0;
    }

    .iconfont {
      cursor: pointer;
    }

    .iconfont:hover {
      color: #7b91ad;
    }
  }

  .tabs-box {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 70px;

    .tabs {
      padding: 5px 15px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 600;
      font-size: 16px;
      color: #9e9e9e;
      line-height: 19px;
      cursor: pointer;
      position: relative;
    }

    .tabs:hover,
    .tabs.active {
      color: #04d1b8;

      .line {
        width: 28px;
        height: 3px;
        background: #04d1b8;
        margin: 5px auto;
        position: absolute;
        left: calc(50% - 14px);
        bottom: -8px;
      }
    }
  }
}
</style>
